cc.Class({
    extends: cc.Component,

    properties: {
        stateSpriteFrame: [cc.SpriteFrame],
        stateColor: [cc.Color]
    },
    editor: {
        menu: 'ExtendUI/SpriteState',
        requireComponent: cc.Sprite,
    },

    // use this for initialization
    onLoad: function () {
    },
    setState: function(stateIndex) {
        var spriteFrame = this.stateSpriteFrame[stateIndex];
        var color = this.stateColor[stateIndex];

        if (spriteFrame) {
            this.getComponent(cc.Sprite).spriteFrame = spriteFrame;
        }
        else {
            this.getComponent(cc.Sprite).spriteFrame = null;
        }
        if (color) {
            this.node.color = color;
        }
    }
});